/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cinema.model;

import java.util.ArrayList;
import javax.swing.ImageIcon;

/**
 *
 * @author AlisonSM
 */
public class myThread extends Thread implements Runnable {
    public ImageIcon img01 = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/1.jpg");
    public ImageIcon img02 = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/2.jpg");
    public ImageIcon img03 = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/3.jpg");
    public ImageIcon img04 = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/4.jpg");
    public ImageIcon img05 = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/5.jpg");
    public ImageIcon img06 = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/6.jpg");
    public ImageIcon img07 = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/7.jpg");
    public ImageIcon img08 = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/8.jpg");
    public ImageIcon imgAnimada = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/animado.gif");
    private static ArrayList<ImageIcon> imageList = new ArrayList<ImageIcon>();
    private static final int SLEEP_MILLIS = 2000;
    public javax.swing.JLabel label;

    public myThread(javax.swing.JLabel label) {
        imageList.add(img01);
        imageList.add(img02);
        imageList.add(img03);
        imageList.add(img04);
        imageList.add(img05);
        imageList.add(img06);
        imageList.add(img07);
        imageList.add(img08);
        this.label = label;
    }

    public void run() {
        try {
            int i = 0;
            while (true) {
                i = (i+1) % imageList.size();
                label.setIcon((ImageIcon)imageList.get(i));
                java.lang.Thread.sleep(SLEEP_MILLIS);
            }
        } catch (InterruptedException e) {
            System.out.println("Interrupted");
        }
    }
}